from itertools import zip_longest

lab_format="[lab{idx:0>2d}](./lab/lab{idx:0>2d})"
hw_format="[hw{idx:0>2d}](./hw/hw{idx:0>2d})"
project_format="[{name}](./projects/{project})"

README="""
本项目整理了CS61A课程的所有作业、lab和project
课程使用[2021 SP](https://inst.eecs.berkeley.edu/~cs61a/sp21/)

|lab|review|homework|review|project|review|
|----|----|----|----|----|----|
{table_content}

TODO:
{todo_content}

## 值得进一步思考的问题
1. Undecidable problems
"""

# |{labs}|{homeworks}|{projects}|

# ## homework
# {homeworks}

# ## project
# {projects}

labs = []
labs_review = [False, False, True, False, False,
               False, False, False, False, False,
               False, False, False, False, True]
for i in range(15):
  labs.append(lab_format.format(idx=i))

homeworks = []
homeworks_review = [False, True, False, False, False,
                    False, False, False, False]
for i in range(1, 10):
  homeworks.append(hw_format.format(idx=i))


pros = ["hog", "cats", "ants", "scheme", "scheme_stubbed"]

projects = []
projects_review = [False, False, False, False, False]
for p in pros:
  projects.append(project_format.format(name=p, project=p))


table_content=""
for lab, lab_review, hw, hw_review, project, project_review in zip_longest(labs, labs_review, homeworks, 
                                    homeworks_review, projects, projects_review):
  table_content += "|{}|{}|{}|{}|{}|{}|\n".format(lab, lab_review, hw, hw_review, project, project_review)
# dicts = {
#   "labs": labs,
#   "homeworks": homeworks,
#   "projects": projects
# }

todo_list=[
  (False, "回头总结一下学到的东西"),
  (False, "虽然是optional，但是scheme_stubbed的尾递归未实现"),
  (False, "scheme_stubbed的个人实现过于暴力，没有用到提供的Expressio和Value抽象"),
  (False, "有时间做一下scheme的简单版本"),
  (False, "值得思考的一些问题")
]
todo_content=""

for done, text in todo_list:
  prefix = "- [x] " if done else "- [ ] "
  todo_content += prefix + text + "\n"

table={
  "table_content": table_content,
  "todo_content": todo_content
}

f = open('README.md', 'w', encoding='utf-8')
f.write(README.format(**table))